-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
child_process.flushStdio: resume _consuming streams #4071
child_process.flushStdio: resume _consuming streams #4071
Conversation
When a client calls read() with a nonzero argument on a Socket, that Socket sets this._consuming to true. It never sets this._consuming back to false. child_process.flushStdio currently doesn't flush any streams where _consuming is truthy. But that means that it never flushes any stream that has ever been read from. This prevents a child process from ever closing if one of its streams has been read from, causing issue nodejs#4049. child_process.flushStdio should flush streams even if their _consuming is set to true. Then it will close even after a read.
cc @nodejs/streams |
const cp = require('child_process'); | ||
const common = require('../common'); | ||
|
||
var p = cp.spawn('yes'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is yes
a valid Windows command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had my coworker on windows type yes into the prompt and it is not a command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also confirm it is not.
Is there a reason the test needs to be in |
A couple of questions about the test, but mostly LGTM. I would like sign off from a streams person if possible. |
I moved the test into |
const cp = require('child_process'); | ||
const common = require('../common'); | ||
|
||
var p = cp.spawn('echo'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please make this const
.
Make the spawned process object a const, and add assertions to the event handler that the arguments are as expected
I made |
Started a CI run: https://ci.nodejs.org/job/node-test-pull-request/883/ The linter doesn't like your indentation - https://ci.nodejs.org/job/node-test-linter/434/console |
@cjihrig note: currently the CI is private. See #4029 (comment) |
How embarrassing. I've indented the requisite two spaces. Forsooth I can't see anything at the CI link. |
@davidvgalbraith could you run |
|
@Fishrock123 good catch about the CI being private. @davidvgalbraith the CI looks fine. There were a couple failures unrelated to this change. LGTM |
When a client calls read() with a nonzero argument on a Socket, that Socket sets this._consuming to true. It never sets this._consuming back to false. ChildProcess.flushStdio() currently doesn't flush any streams where _consuming is truthy. But, that means that it never flushes any stream that has ever been read from. This prevents a child process from ever closing if one of its streams has been read from, causing issue #4049. This commit allows consuming streams to be flushed, and the child process to emit a close event. Fixes: #4049 PR-URL: #4071 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Thanks! Landed in 34b535f |
@cjihrig ... would you consider this a bug fix (and thus suitable for LTS) or an add? |
I would consider this a bug fix. |
Looks like this new test here is failing on CentOS: https://ci.nodejs.org/job/node-test-commit-linux/1387/nodes=centos5-32/tapResults/
|
Yes. See #4125 |
When a client calls read() with a nonzero argument on a Socket, that Socket sets this._consuming to true. It never sets this._consuming back to false. ChildProcess.flushStdio() currently doesn't flush any streams where _consuming is truthy. But, that means that it never flushes any stream that has ever been read from. This prevents a child process from ever closing if one of its streams has been read from, causing issue #4049. This commit allows consuming streams to be flushed, and the child process to emit a close event. Fixes: #4049 PR-URL: #4071 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Not going to land this until we are ready to land #4215 into LTS... I think it needs a bit more time |
When a client calls read() with a nonzero argument on a Socket, that Socket sets this._consuming to true. It never sets this._consuming back to false. ChildProcess.flushStdio() currently doesn't flush any streams where _consuming is truthy. But, that means that it never flushes any stream that has ever been read from. This prevents a child process from ever closing if one of its streams has been read from, causing issue #4049. This commit allows consuming streams to be flushed, and the child process to emit a close event. Fixes: #4049 PR-URL: #4071 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
When a client calls read() with a nonzero argument on a Socket, that Socket sets this._consuming to true. It never sets this._consuming back to false. ChildProcess.flushStdio() currently doesn't flush any streams where _consuming is truthy. But, that means that it never flushes any stream that has ever been read from. This prevents a child process from ever closing if one of its streams has been read from, causing issue #4049. This commit allows consuming streams to be flushed, and the child process to emit a close event. Fixes: #4049 PR-URL: #4071 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
When a client calls read() with a nonzero argument on a Socket, that Socket sets this._consuming to true. It never sets this._consuming back to false. ChildProcess.flushStdio() currently doesn't flush any streams where _consuming is truthy. But, that means that it never flushes any stream that has ever been read from. This prevents a child process from ever closing if one of its streams has been read from, causing issue nodejs#4049. This commit allows consuming streams to be flushed, and the child process to emit a close event. Fixes: nodejs#4049 PR-URL: nodejs#4071 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Hey! I'm new here. Tried to follow all the guidelines. Thanks for your attention!
When a client calls read() with a nonzero argument
on a Socket, that Socket sets this._consuming to true.
It never sets this._consuming back to false.
child_process.flushStdio currently doesn't flush
any streams where _consuming is truthy. But that means
that it never flushes any stream that has ever been read from.
This prevents a child process from ever closing if one of
its streams has been read from, causing issue #4049.
child_process.flushStdio should flush streams even if their
_consuming is set to true. Then it will close even after a read.